package com.qianfeng.smartdevice.mapper;

import com.qianfeng.smartdevice.pojo.SysUserInfo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by wenka on 2022/3/14 16:38
 *
 * @author Jackiechan
 * @version 1.0
 * @since 1.0
 */
public interface SysUserInfoMapper {
    /**
     * 根据用户id查询
     * @param userId
     * @return
     */
    @Select("select * from sys_user_info where u_id=#{userId}")
    SysUserInfo findById(Long userId);

    /**
     * 查询所有用户信息
     * @return
     */
    @Select("select * from sys_user_info")
    List<SysUserInfo> findAll();

    /**
     * 添加新的用户
     * @param sysUserInfo
     */
    void addUser(SysUserInfo sysUserInfo);

    /**
     * 根据用户名查询用户信息
     * @param username
     * @return
     */
    @Select("SELECT * FROM sys_user_info WHERE username=#{username}")
    SysUserInfo findByUsername(String username);

    /**
     * 根据手机号查询用户信息
     * @param phonenum
     * @return
     */
    @Select("SELECT * FROM sys_user_info WHERE phone=#{phonenum}")
    SysUserInfo findByPhone(String phonenum);

    /**
     * 根据邮箱查询信息
     * @param email
     * @return
     */
    @Select("SELECT * FROM sys_user_info WHERE email=#{email}")
    SysUserInfo findByEmail(String email);

    /**
     * 根据用户名密码查询
     * @param username 用户名
     * @param password 密码
     * @return
     */
    @Select("select * from sys_user_info where username=#{username} and password=#{password}")
    SysUserInfo findByUserNameAndPassword(String username,String password);

}
